$(document).ready(function () {
    time();
    BloodHeart();
    HeartRate();
    BloodOxygen();
    GetAge();
    BreathRank();
    LegRank();
    var heart = $("input[name='heart']").val();
    if ($("#sex").html() == "M") {
        $("#sex").html("男")
    }
    else {
        $("#sex").html("女")
    }
    $("input[name='dialysisradio']").each(function () {
        var $this = $(this);
        if ($this.val() == heart) {
            $this.iCheck('check');
        } else {
            $this.iCheck('uncheck');
        }
    });
    $('.square-blue input').iCheck({
        checkboxClass: 'icheckbox_square-blue',
        radioClass: 'iradio_square-blue',
        increaseArea: '20%' // optional
    });
    $('.SixwalkTimeBox-monthbox-month').click(function () {
        var openclose = $(this).parent().find('.SixwalkTimeBox-monthbox-contentbox');
        if (openclose.hasClass('month-open-close')) {
            openclose.removeClass('month-open-close');
            $(this).css({'background': '#2d8cda', 'border': '1px solid #2d8cda'});
        } else {
            openclose.addClass('month-open-close');
            $(this).css({'background': '#676b98', 'border': '1px solid #676b98'});
        }
    });


});

function BreathRank() {
    var breathRank = $("input[name='breathRank']").val();
    var remark2 = $("input[name='remark2']").val();
    if (breathRank == '0') {
        $('#breathRank').addClass('grade1');
        $('#breathRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (breathRank == '0.5') {
        $('#breathRank').addClass('grade2');
        $('#breathRank').removeClass('grade1 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (breathRank == '1') {
        $('#breathRank').addClass('grade3');
        $('#breathRank').removeClass('grade1 grade2 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (breathRank == '2') {
        $('#breathRank').addClass('grade4');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (breathRank == '3') {
        $('#breathRank').addClass('grade5');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade6 grade7 grade8 grade9 grade10');
    } else if (breathRank == '4') {
        $('#breathRank').addClass('grade6');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade7 grade8 grade9 grade10');
    } else if (breathRank == '5-6') {
        $('#breathRank').addClass('grade7');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade8 grade9 grade10');
    } else if (breathRank == '7-8') {
        $('#breathRank').addClass('grade8');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade9 grade10');
    } else if (breathRank == '9') {
        $('#breathRank').addClass('grade9');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade10');
    } else if (breathRank == '10') {
        $('#breathRank').addClass('grade10');
        $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9');
    } else {
        $('#breathRank').addClass('grade1');
        $('#breathRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
        $('#breathText').html(remark2);
    }
}

function LegRank() {
    var legRank = $("input[name='legRank']").val();
    var remark = $("input[name='remark']").val();
    if (legRank == '0') {
        $('#legRank').addClass('grade1');
        $('#legRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (legRank == '0.5') {
        $('#legRank').addClass('grade2');
        $('#legRank').removeClass('grade1 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (legRank == '1') {
        $('#legRank').addClass('grade3');
        $('#legRank').removeClass('grade1 grade2 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (legRank == '2') {
        $('#legRank').addClass('grade4');
        $('#legRank').removeClass('grade1 grade2 grade3 grade5 grade6 grade7 grade8 grade9 grade10');
    } else if (legRank == '3') {
        $('#legRank').addClass('grade5');
        $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade6 grade7 grade8 grade9 grade10');
    } else if (legRank == '4') {
        $('#legRank').addClass('grade6');
        $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade7 grade8 grade9 grade10');
    } else if (legRank == '5-6') {
        $('#legRank').addClass('grade7');
        $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade8 grade9 grade10');
    } else if (legRank == '7-8') {
        $('#legRank').addClass('grade8');
        $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade9 grade10');
    } else if (legRank == '9') {
        $('#legRank').addClass('grade9');
        $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade10');
    } else if (legRank == '10') {
        $('#legRank').addClass('grade10');
        $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9');
    } else {
        $('#legRank').addClass('grade1');
        $('#legRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
        $('#legText').html(remark);
    }
}

//心率曲线分布图
function HeartRate() {
    var spos = [];
    //查询之前的数据
    $("input[name='spo']").each(function (index, a) {
        spos.push($(this).val());
    })
    var myChart = echarts.init(document.getElementById('SixwalkPatient-heartrate'));
    var option = {
        xAxis: {
            // 控制网格线是否显示
            splitLine: {
                show: false
            },//去除网格线
            type: 'category',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#93b2c7'//x轴文字颜色
                }
            },
            // x轴的颜色和宽度
            axisLine: {
                lineDatastyle: {
                    color: '#0087ed'//x轴颜色
                }
            },
            axisTick: {
                alignWithLabel: true
            },
            data: ['1min', '2min', '3min', '4min', '5min', '6min']
        },
        yAxis: {
            // 控制网格线是否显示
            splitLine: {
                lineDatastyle: {
                    color: '#0087ed',//网格线颜色
                    type: 'dotted'//网格线类型
                }
            },
            type: 'value',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#2b2b2b'
                },
                backgroundColor: '#97cdff',
                borderRadius: 2,
                formatter: function (value) {
                    return '{value|' + value + '}';
                },
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            axisLine: {
                show: false
            },
            // 去除坐标轴上的刻度线
            axisTick: {
                show: false
            },
            max: 150,
            min: 0,
            splitNumber: 5
        },
        series: [{
            label: {
                show: true,
                backgroundColor: '#279e7f',
                borderRadius: 2,
                color: '#fff',
                padding: 3,
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            /* data: [68, 55, 10, 77, 53, 88, 50],*/
            data: spos,
            type: 'line',
            itemStyle: {
                color: '#279e7f'
            },
            lineDatastyle: {
                color: '#279e7f'
            },
            areaStyle: {
                color: '#279e7f'
            }
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
}

//血氧曲线分布图
function BloodOxygen() {
    var hrs = [];
    //查询之前的数据
    $("input[name='hr']").each(function (index, a) {
        hrs.push($(this).val())
    })
    var myChart = echarts.init(document.getElementById('SixwalkPatient-oxygen'));
    var option = {
        xAxis: {
            // 控制网格线是否显示
            splitLine: {
                show: false
            },//去除网格线
            type: 'category',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#93b2c7'//x轴文字颜色
                }
            },
            // x轴的颜色和宽度
            axisLine: {
                lineDatastyle: {
                    color: '#0087ed'//x轴颜色
                }
            },
            axisTick: {
                alignWithLabel: true
            },
            data: ['1min', '2min', '3min', '4min', '5min', '6min']
        },
        yAxis: {
            // 控制网格线是否显示
            splitLine: {
                lineDatastyle: {
                    color: '#0087ed',//网格线颜色
                    type: 'dotted'//网格线类型
                }
            },
            type: 'value',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#2b2b2b'
                },
                backgroundColor: '#e4b3fa',
                borderRadius: 2,
                formatter: function (value) {
                    return '{value|' + value + '}';
                },
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            axisLine: {
                show: false
            },
            // 去除坐标轴上的刻度线
            axisTick: {
                show: false
            },
            max: 100,
            min: 0,
            splitNumber: 5
        },

        series: [{
            label: {
                show: true,
                backgroundColor: '#2b77b6',
                borderRadius: 2,
                color: '#fff',
                padding: 3,
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            /*  data: [68, 65, 70, 77, 99, 88, 80],*/
            data: hrs,
            type: 'line',
            itemStyle: {
                color: '#2b77b6'
            },
            lineDatastyle: {
                color: '#2b77b6'
            },
            areaStyle: {
                color: '#2b77b6'
            }
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
}

function BloodHeart() {
    var BloodStamp = [];
    $("input[name='spo']").each(function (index, a) {
        BloodStamp.push($(this).val());
        var m = index + 1;
        for (var i = 1; i < m + 1; i++) {
            $('#spo' + i).css({'width': BloodStamp[i - 1] / 2 + '%'});
        }
    });
    var HeartStamp = [];
    $("input[name='hr']").each(function (index, a) {
        HeartStamp.push($(this).val());
        var n = index + 1;
        for (var i = 1; i < n + 1; i++) {
            $('#hr' + i).css({'width': HeartStamp[i - 1] / 220 * 50 + '%'});
        }
    });
}

function time() {
    var timeStamp = [];
    $("input[name='time']").each(function (index, a) {
        timeStamp.push($(this).val())
        j = index
    });
    if (timeStamp.length != 0) {
        var date = new Date(timeStamp[0]);
        var html = '<div class="SixwalkTimeBox-year-title" >' + date.getFullYear() + '</div>'
            + '<div class="SixwalkTimeBox-year-content" >'
            + '<div class="SixwalkTimeBox-monthbox" id="month0">'
            + '<div class="SixwalkTimeBox-monthbox-month" >' + (date.getMonth() + 1) + '月</div>'
            + '<div class="SixwalkTimeBox-monthbox-content" >'
            + '<div class="SixwalkTimeBox-monthbox-contentbox month-open-close" >'
            + '<div class="SixwalkTimeBox-daybox" id="day0">'
            + '<div class="SixwalkTimeBox-daybox-day" >' + (date.getMonth() + 1) + '-' + date.getDate() + '</div>'
            + '<div class="SixwalkTimeBox-daybox-content" >'
            + '<div class="SixwalkTimeBox-daybox-day-content" id="hours0" onclick="loadDate(0)">' + date.getHours() + ':' + date.getMinutes() + '</div>'
            + '</div>'
            + '</div>'
            + '</div>'
            + '</div>'
            + '</div>'
            + '</div>';
        $('#timeBox').html(html);
        var strHtml;
        var date1;
        var date2;
        var j;
        for (var i = 0; i < j; i++) {
            date1 = new Date(timeStamp[i])
            date2 = new Date(timeStamp[i + 1])
            if (date1.getFullYear() == date2.getFullYear()) {
                if (date1.getMonth() == date2.getMonth()) {
                    if (date1.getDate() == date2.getDate()) {
                        strHtml = '<div class="SixwalkTimeBox-daybox-day-content" onclick="loadDate(' + (i + 1) + ')" id="hours' + (i + 1) + '">' + date2.getHours() + ':' + date2.getMinutes() + '</div>'
                        $('#hours' + i).after(strHtml)
                    } else {
                        strHtml = '<div class="SixwalkTimeBox-daybox" >'
                            + '<div class="SixwalkTimeBox-daybox-day">' + (date2.getMonth() + 1) + '-' + date2.getDate() + '</div>'
                            + '<div class="SixwalkTimeBox-daybox-content" >'
                            + '<div class="SixwalkTimeBox-daybox-day-content" onclick="loadDate(' + (i + 1) + ')" id="hours' + (i + 1) + '">' + date2.getHours() + ':' + date2.getMinutes() + '</div>'
                            + '</div>'
                            + '</div>'
                        $('#hours' + i).parent().parent().parent().append(strHtml)
                    }
                } else {
                    strHtml = '<div class="SixwalkTimeBox-monthbox" >'
                        + '<div class="SixwalkTimeBox-monthbox-month" >' + (date2.getMonth() + 1) + '月</div>'
                        + '<div class="SixwalkTimeBox-monthbox-content" >'
                        + '<div class="SixwalkTimeBox-monthbox-contentbox month-open-close" >'
                        + '<div class="SixwalkTimeBox-daybox" >'
                        + '<div class="SixwalkTimeBox-daybox-day" >' + (date2.getMonth() + 1) + '-' + date2.getDate() + '</div>'
                        + '<div class="SixwalkTimeBox-daybox-content" >'
                        + '<div class="SixwalkTimeBox-daybox-day-content"  onclick="loadDate(' + (i + 1) + ')" id="hours' + (i + 1) + '">' + date2.getHours() + ':' + date2.getMinutes() + '</div>'
                        + '</div>'
                        + '</div>'
                        + '</div>'
                        + '</div>'
                        + '</div>';
                    $('#hours' + i).parent().parent().parent().parent().parent().parent().append(strHtml)
                }
            } else {
                strHtml = '<div class="SixwalkTimeBox-year"  >'
                    + '<div class="SixwalkTimeBox-year-title" >' + date2.getFullYear() + '</div>'
                    + '<div class="SixwalkTimeBox-year-content" >'
                    + '<div class="SixwalkTimeBox-monthbox" >'
                    + '<div class="SixwalkTimeBox-monthbox-month" >' + (date2.getMonth() + 1) + '月</div>'
                    + '<div class="SixwalkTimeBox-monthbox-content" >'
                    + '<div class="SixwalkTimeBox-monthbox-contentbox month-open-close" >'
                    + '<div class="SixwalkTimeBox-daybox" >'
                    + '<div class="SixwalkTimeBox-daybox-day" >' + (date2.getMonth() + 1) + '-' + date2.getDate() + '</div>'
                    + '<div class="SixwalkTimeBox-daybox-content" >'
                    + '<div class="SixwalkTimeBox-daybox-day-content" onclick="loadDate(' + (i + 1) + ')" id="hours' + (i + 1) + '">' + date2.getHours() + ':' + date2.getMinutes() + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>';
                $('#hours' + i).parent().parent().parent().parent().parent().parent().parent().parent().append(strHtml)
            }

        }
    }

}

function loadDate(index) {
    var ids = []
    $("input[name='walkId']").each(function () {
        ids.push($(this).val());
    });
    $('.SixwalkTimeBox-daybox-day-content').removeClass('dayclick');
    $('#hours' + index).addClass('dayclick');
    var id = ids[index];
    var url = '/ui/sixwalk/report/' + id;
    $.ajax({
        url: url,
        type: 'GET',
        success: function (data) {
            var result = data.obj;
            console.log(result);
            var spos = [];
            var hrs = [];
            var heart = result.heartLung;
            $("input[name='dialysisradio']").each(function () {
                var $this = $(this);
                if ($this.val() == heart) {
                    $this.iCheck('check');
                } else {
                    $this.iCheck('uncheck');
                }
            });
            $('.square-blue input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' // optional
            });
            if (result.met != null) {
                $('#mets').html(result.met + 'METS')
            } else {
                $('#mets').html('暂无METS')
            }
            $('#distance').html('共行走了' + result.distance + '米 （每圈' + result.meters + '米）')
            $('#startsbp').html(result.startSbp + '/')
            $('#startdbp').html(result.startDbp)
            $('#stopsbp').html(result.stopSbp + '/')
            $('#stopdbp').html(result.stopDbp)
            if (result.lineDatas.length == 0){
                for (i = 0; i < 6; i++) {
                    spos.push(0)
                    hrs.push(0)
                }
            } else {
                for (i = 0; i < result.lineDatas.length; i++) {
                    spos.push(result.lineDatas[i].spo2)
                    hrs.push(result.lineDatas[i].hr)
                }
            }

            var boxhtml = `<div class="SixwalkPatientBsbphr-lbox-content" >
                <div class="SixwalkPatientBsbphr-lbox-time">1min</div>
            <div class="SixwalkPatientBsbphr-lbox-ratio">
                <div class="SixwalkPatientBsbphr-lbox-ratio1" id="spo1"
            ></div>
                <div class="SixwalkPatientBsbphr-lbox-ratio2" id="hr1" ></div>
                </div>
                </div>
                <div class="SixwalkPatientBsbphr-lbox-content" >
                <div class="SixwalkPatientBsbphr-lbox-time">2min</div>
            <div class="SixwalkPatientBsbphr-lbox-ratio">
                <div class="SixwalkPatientBsbphr-lbox-ratio1" id="spo2"
            ></div>
                <div class="SixwalkPatientBsbphr-lbox-ratio2" id="hr2" ></div>
                </div>
                </div>
                <div class="SixwalkPatientBsbphr-lbox-content" >
                <div class="SixwalkPatientBsbphr-lbox-time">3min</div>
            <div class="SixwalkPatientBsbphr-lbox-ratio">
                <div class="SixwalkPatientBsbphr-lbox-ratio1" id="spo3"
            ></div>
                <div class="SixwalkPatientBsbphr-lbox-ratio2" id="hr3" ></div>
                </div>
                </div>
                <div class="SixwalkPatientBsbphr-lbox-content" >
                <div class="SixwalkPatientBsbphr-lbox-time">4min</div>
            <div class="SixwalkPatientBsbphr-lbox-ratio">
                <div class="SixwalkPatientBsbphr-lbox-ratio1" id="spo4"
            ></div>
                <div class="SixwalkPatientBsbphr-lbox-ratio2" id="hr4" ></div>
                </div>
                </div>
                <div class="SixwalkPatientBsbphr-lbox-content" >
                <div class="SixwalkPatientBsbphr-lbox-time">5min</div>
            <div class="SixwalkPatientBsbphr-lbox-ratio">
                <div class="SixwalkPatientBsbphr-lbox-ratio1" id="spo5"
            ></div>
                <div class="SixwalkPatientBsbphr-lbox-ratio2" id="hr5" ></div>
                </div>
                </div>
                <div class="SixwalkPatientBsbphr-lbox-content" >
                <div class="SixwalkPatientBsbphr-lbox-time">6min</div>
            <div class="SixwalkPatientBsbphr-lbox-ratio">
                <div class="SixwalkPatientBsbphr-lbox-ratio1" id="spo6"
            ></div>
                <div class="SixwalkPatientBsbphr-lbox-ratio2" id="hr6" ></div>
                </div>
                </div>
`
            $("#SixwalkPatientBsbphr-lbox-content").html(boxhtml);
            $("#spo1").html(spos[0] + '%');
            $("#spo1").css({'width': spos[0] / 2 + '%'});

            $("#spo2").html(spos[1] + '%');
            $("#spo2").css({'width': spos[1] / 2 + '%'});
            $("#spo3").html(spos[2] + '%');
            $("#spo3").css({'width': spos[2] / 2 + '%'});
            $("#spo4").html(spos[3] + '%');
            $("#spo4").css({'width': spos[3] / 2 + '%'});
            $("#spo5").html(spos[4] + '%');
            $("#spo5").css({'width': spos[4] / 2 + '%'});
            $("#spo6").html(spos[5] + '%');
            $("#spo6").css({'width': spos[5] / 2 + '%'});
            $("#hr1").html(hrs[0] + 'bpm');
            $("#hr1").css({'width': hrs[0] / 220 * 50 + '%'});
            $("#hr2").html(hrs[1] + 'bpm');
            $("#hr2").css({'width': hrs[1] / 220 * 50 + '%'});
            $("#hr3").html(hrs[2] + 'bpm');
            $("#hr3").css({'width': hrs[2] / 220 * 50 + '%'});
            $("#hr4").html(hrs[3] + 'bpm');
            $("#hr4").css({'width': hrs[3] / 220 * 50 + '%'});
            $("#hr5").html(hrs[4] + 'bpm');
            $("#hr5").css({'width': hrs[4] / 220 * 50 + '%'});
            $("#hr6").html(hrs[5] + 'bpm');
            $("#hr6").css({'width': hrs[5] / 220 * 50 + '%'});

            $("#breathRank").html(result.borgbreathRank);
            $("#breathText").html(result.borgbreathText);
            if (result.borgbreathRank == '0') {
                $('#breathRank').addClass('grade1');
                $('#breathRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '0.5') {
                $('#breathRank').addClass('grade2');
                $('#breathRank').removeClass('grade1 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '1') {
                $('#breathRank').addClass('grade3');
                $('#breathRank').removeClass('grade1 grade2 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '2') {
                $('#breathRank').addClass('grade4');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '3') {
                $('#breathRank').addClass('grade5');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '4') {
                $('#breathRank').addClass('grade6');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade7 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '5-6') {
                $('#breathRank').addClass('grade7');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade8 grade9 grade10');
            } else if (result.borgbreathRank == '7-8') {
                $('#breathRank').addClass('grade8');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade9 grade10');
            } else if (result.borgbreathRank == '9') {
                $('#breathRank').addClass('grade9');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade10');
            } else if (result.borgbreathRank == '10') {
                $('#breathRank').addClass('grade10');
                $('#breathRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9');
            } else {
                $('#breathRank').addClass('grade1');
                $('#breathRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
                $('#breathText').html(result.remark2);
            }

            $("#legRank").html(result.borglegRank);
            $("#legText").html(result.borglegText);
            if (result.borglegRank == '0') {
                $('#legRank').addClass('grade1');
                $('#legRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borglegRank == '0.5') {
                $('#legRank').addClass('grade2');
                $('#legRank').removeClass('grade1 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borglegRank == '1') {
                $('#legRank').addClass('grade3');
                $('#legRank').removeClass('grade1 grade2 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borglegRank == '2') {
                $('#legRank').addClass('grade4');
                $('#legRank').removeClass('grade1 grade2 grade3 grade5 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borglegRank == '3') {
                $('#legRank').addClass('grade5');
                $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade6 grade7 grade8 grade9 grade10');
            } else if (result.borglegRank == '4') {
                $('#legRank').addClass('grade6');
                $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade7 grade8 grade9 grade10');
            } else if (result.borglegRank == '5-6') {
                $('#legRank').addClass('grade7');
                $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade8 grade9 grade10');
            } else if (result.borglegRank == '7-8') {
                $('#legRank').addClass('grade8');
                $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade9 grade10');
            } else if (result.borglegRank == '9') {
                $('#legRank').addClass('grade9');
                $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade10');
            } else if (result.borglegRank == '10') {
                $('#legRank').addClass('grade10');
                $('#legRank').removeClass('grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9');
            } else {
                $('#legRank').addClass('grade1');
                $('#legRank').removeClass('grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10');
                $('#legText').html(result.remark);
            }


            xinlv(spos);
            xueyang(hrs);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log(errorThrown);
        },
        dataType: "json",
        async: true
    });
}

function xinlv(spos) {
    var myChart = echarts.init(document.getElementById('SixwalkPatient-heartrate'));
    var option = {
        xAxis: {
            // 控制网格线是否显示
            splitLine: {
                show: false
            },//去除网格线
            type: 'category',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#93b2c7'//x轴文字颜色
                }
            },
            // x轴的颜色和宽度
            axisLine: {
                lineDatastyle: {
                    color: '#0087ed'//x轴颜色
                }
            },
            axisTick: {
                alignWithLabel: true
            },
            data: ['1min', '2min', '3min', '4min', '5min', '6min']
        },
        yAxis: {
            // 控制网格线是否显示
            splitLine: {
                lineDatastyle: {
                    color: '#0087ed',//网格线颜色
                    type: 'dotted'//网格线类型
                }
            },
            type: 'value',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#2b2b2b'
                },
                backgroundColor: '#97cdff',
                borderRadius: 2,
                formatter: function (value) {
                    return '{value|' + value + '}';
                },
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            axisLine: {
                show: false
            },
            // 去除坐标轴上的刻度线
            axisTick: {
                show: false
            },
            max: 150,
            min: 0,
            splitNumber: 5
        },
        series: [{
            label: {
                show: true,
                backgroundColor: '#279e7f',
                borderRadius: 2,
                color: '#fff',
                padding: 3,
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            /* data: [68, 55, 10, 77, 53, 88, 50],*/
            data: spos,
            type: 'line',
            itemStyle: {
                color: '#279e7f'
            },
            lineDatastyle: {
                color: '#279e7f'
            },
            areaStyle: {
                color: '#279e7f'
            }
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
}

function xueyang(hrs) {
    var myChart = echarts.init(document.getElementById('SixwalkPatient-oxygen'));
    var option = {
        xAxis: {
            // 控制网格线是否显示
            splitLine: {
                show: false
            },//去除网格线
            type: 'category',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#93b2c7'//x轴文字颜色
                }
            },
            // x轴的颜色和宽度
            axisLine: {
                lineDatastyle: {
                    color: '#0087ed'//x轴颜色
                }
            },
            axisTick: {
                alignWithLabel: true
            },
            data: ['1min', '2min', '3min', '4min', '5min', '6min']
        },
        yAxis: {
            // 控制网格线是否显示
            splitLine: {
                lineDatastyle: {
                    color: '#0087ed',//网格线颜色
                    type: 'dotted'//网格线类型
                }
            },
            type: 'value',
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#2b2b2b'
                },
                backgroundColor: '#e4b3fa',
                borderRadius: 2,
                formatter: function (value) {
                    return '{value|' + value + '}';
                },
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            axisLine: {
                show: false
            },
            // 去除坐标轴上的刻度线
            axisTick: {
                show: false
            },
            max: 100,
            min: 0,
            splitNumber: 5
        },

        series: [{
            label: {
                show: true,
                backgroundColor: '#2b77b6',
                borderRadius: 2,
                color: '#fff',
                padding: 3,
                rich: {
                    value: {
                        width: 30,
                        height: 15,
                        align: 'center'
                    }
                }
            },
            /*  data: [68, 65, 70, 77, 99, 88, 80],*/
            data: hrs,
            type: 'line',
            itemStyle: {
                color: '#2b77b6'
            },
            lineDatastyle: {
                color: '#2b77b6'
            },
            areaStyle: {
                color: '#2b77b6'
            }
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
}

function GetAge() {
    var identityCard = $("#rAge").html();
    var len = (identityCard + "").length;
    if (len == 0) {
        return 0;
    } else {
        if ((len != 15) && (len != 18))//身份证号码只能为15位或18位其它不合法
        {
            return 0;
        }
    }
    var strBirthday = "";
    if (len == 18)//处理18位的身份证号码从号码中得到生日和性别代码
    {
        strBirthday = identityCard.substr(6, 4) + "/" + identityCard.substr(10, 2) + "/" + identityCard.substr(12, 2);
    }
    if (len == 15) {
        strBirthday = "19" + identityCard.substr(6, 2) + "/" + identityCard.substr(8, 2) + "/" + identityCard.substr(10, 2);
    }
    //时间字符串里，必须是“/”
    var birthDate = new Date(strBirthday);
    var nowDateTime = new Date();
    var age = nowDateTime.getFullYear() - birthDate.getFullYear();
    //再考虑月、天的因素;.getMonth()获取的是从0开始的，这里进行比较，不需要加1
    if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) {
        age--;
    }
    $("#rAge").html(age);
}

	